import subprocess
import os

path = "/test666/"
url = "www.baid.com/kylin-revision-manager-sources1.json"

check_cmd = ['wget', '--spider', url]
try:
    result = subprocess.run(check_cmd, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    print("url is vaild")
    # URL有效，执行下载
    # download_cmd = ['wget', '-c', '-P', path, url, '-T', '5', '--progress=dot']
    # download_result = subprocess.run(download_cmd, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    # print("Download completed successfully.")
    # print("Download output:", download_result.stdout.decode())
except Exception as e:
    print("URL is invalid or inaccessible.")




'''
cmdList = ['wget', '-c', '-P', path, url, '-T', '5', '--progress=dot']
isoSP = subprocess.Popen(cmdList)
out, err = isoSP.communicate()
ret = isoSP.returncode

print("ret:", ret)
print("out:", out)
print("err:", err)
'''